<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>已购套餐 - <?= $systemConfig['system_name'] ?? '' ?></title>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<style>*{margin:0;padding:0;box-sizing:border-box;}body{background:#f5f7fa;font-family:"Microsoft YaHei","PingFang SC",sans-serif;}
.header{background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.08);}.header .inner{max-width:1200px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;padding:0 20px;height:60px;}
.header .logo{font-size:20px;font-weight:700;color:#1e3c72;text-decoration:none;}.header .nav{display:flex;gap:16px;}
.header .nav a{color:#555;text-decoration:none;font-size:14px;padding:8px 12px;border-radius:4px;}.header .nav a:hover,.header .nav a.active{color:#1e9fff;background:#f0f7ff;}
.container{max-width:1100px;margin:0 auto;padding:20px;}.card{background:#fff;border-radius:8px;padding:20px;box-shadow:0 2px 8px rgba(0,0,0,.05);margin-bottom:20px;}
.card h3{font-size:17px;margin-bottom:14px;color:#333;padding-bottom:10px;border-bottom:1px solid #eee;}</style>
</head>
<body>
<div class="header"><div class="inner">
    <a href="/" class="logo"><?= $systemConfig['system_name'] ?? '' ?></a>
    <div class="nav"><a href="/user/index/dashboard">控制台</a><a href="/user/index/packages">套餐市场</a><a href="/user/index/myApps">我的应用</a><a href="/user/index/callStats">调用统计</a><a href="/user/index/myOrders">我的订单</a><a href="/user/index/myPackages" class="active">已购套餐</a><a href="/user/index/recharge">余额充值</a><a href="/user/index/apiDoc">接入文档</a><a href="/user/index/profile"><?= $userInfo['nickname'] ?? $userInfo['username'] ?></a><a href="/user/index/logout">退出</a></div>
</div></div>
<div class="container">
    <div class="card">
        <h3>已购套餐</h3>
        <?php if(!empty($myPackages)): ?>
        <table class="layui-table" lay-size="sm">
            <thead><tr><th>套餐名称</th><th>通道</th><th>购买时间</th><th>到期时间</th><th>调用次数</th><th>状态</th></tr></thead>
            <tbody>
                <?php foreach($myPackages as $pkg): ?>
                <tr>
                    <td><?= $pkg['package_name'] ?></td>
                    <td><?= $pkg['channel_name'] ?: '-' ?></td>
                    <td><?= $pkg['pay_time'] ?? $pkg['create_time'] ?></td>
                    <td><?= date('Y-m-d H:i:s', $pkg['expire_ts']) ?></td>
                    <td><?= $pkg['call_limit'] ?></td>
                    <td><?= $pkg['expired'] ? '<span style="color:red">已过期</span>' : '<span style="color:green">有效</span>' ?></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <?php else: ?>
        <div style="text-align:center;padding:40px;color:#999;">暂无已购套餐，<a href="/user/index/dashboard#packages-section" style="color:#1e9fff;">去购买</a></div>
        <?php endif; ?>
    </div>
</div>
</body>
</html>